Dart.Mail Namespace > TcpBase Class > Read Method : Read(Byte[]) Method |
public: Data^ Read( array<byte>^ buffer )
This method performs a single socket read, blocking until at least one byte is read, up to as much data as is available on the socket or buffer.Length, whichever is lowest.
This method will block until data is available or the ReceiveTimeout has expired.
private void button1_Click(object sender, EventArgs e) { myComponent.Start(readLoopWorker, null); } private void readLoopWorker(object state) { byte[] buffer = new byte[1024]; Data data = myComponent.Read(buffer); while (data != null) { myComponent.Marshal(data, "", null); data = myComponent.Read(buffer); } myComponent.Close(); } void myComponent_Data(object sender, Dart.Sockets.DataEventArgs e) { textBox1.AppendText(e.Data.ToString()); }
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) myComponent.Start(AddressOf readLoopWorker, Nothing) End Sub Private Sub readLoopWorker(ByVal state As Object) Dim buffer(1023) As Byte Dim data As Data = myComponent.Read(buffer) Do While data IsNot Nothing myComponent.Marshal(data, "", Nothing) data = myComponent.Read(buffer) Loop myComponent.Close() End Sub Private Sub myComponent_Data(ByVal sender As Object, ByVal e As Dart.Sockets.DataEventArgs) textBox1.AppendText(e.Data.ToString()) End Sub